home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / fweb / fweb-1.30 / manual / fwebmac.web (.txt) < prev    next >
Encoding:
Texinfo Document  |  1993-06-16  |  42.7 KB  |  1,008 lines

  1. @z --- fwebmac.web ---
  2. Copyright (C) 1987 Princeton University
  3. Original authors:  D. Knuth, S. Levy
  4. Upgraded by J.A. Krommes for FWEB version 1.30--beta (January 1, 1993)
  5. @x-----------------------------------------------------------------------------
  6. \Title{FWEBMAC}
  7. @* INTRODUCTION.  These are the standard macros for \FWEB\ (v.~1.30)
  8. listings (in addition to those of \.{PLAIN.TEX} and/or \LaTeX).
  9. WARNING: Some of these macros are not independent of stuff hard-coded
  10. into \FWEAVE. In other words, if you change something here, you may also need
  11. to recompile \FWEAVE. So caution!
  12. @ Print a comment at the beginning of the \.{.sty} file that is created.
  13. % --- THIS IS fwebmac.sty ---
  14. % This file must be included into all .tex files produced by FWEAVE.  For
  15. % the source for this file, please see fwebmac.web.
  16. % ---------------------------------------------------------------------------
  17. @ First, we have a flag |\FWEBisloaded| that prevents \.{fwebmac.sty} from
  18. being loaded twice.  For the use of this flag, see the Dirty Tricks
  19. appendix of the \TeX book. 
  20. % If it's not defined yet, load in the macros.
  21. \ifx\FWEBisloaded\relax\endinput\else\let\FWEBisloaded\relax\fi
  22. @ Various things need to know the current version number and date.
  23. \def\FWEBversion{1.30}
  24. \def\FWEBdate{June 10, 1993}
  25. @ \FWEB\ now works with \LaTeX, after a fashion. Here's how to refer to it
  26. (borrowed from \LaTeX's \.{\\p@@LaTeX} macro):
  27. \def\LaTeX{{\rm L\kern-0.36em\raise0.3ex\hbox{\Csc a}\kern-0.15em T%
  28.     \kern-0.1667em \lower0.7ex\hbox{E}\kern-0.125em X}}
  29. @ We need to distinguish whether or not \LaTeX\ is loaded.  Assuming that
  30. only \TeX\ or \LaTeX\ will be used, one way of doing this is to
  31. discriminate on whether |\pageno| is defined.  
  32. \newif\ifLaTeXisloaded
  33. \ifx\pageno\undefined
  34.     \LaTeXisloadedtrue
  35. @ \FWEB\ now supports \LaTeX's NFSS (new font selection scheme).  Macros
  36. courtesy of Charles Karney, Princeton U.
  37. \ifx\selectfont\undefined\else
  38.     \fontsize{10}{12pt}\rm % The standard font for bulk of document.
  39. @ If \LaTeX\ is loaded, we equate |\pageno| to \LaTeX's counter so that the
  40. |\label| macro works correctly.  Also, \LaTeX\ does its own thing with the
  41. |\end| command.
  42. \catcode`\@@=11
  43. \ifLaTeXisloaded
  44.     \let\pageno\c@@page% \WEB\ has its own name for the page number.
  45.     \def\FWEBend{\let\clearpage\newpage% Otherwise, one gets a blank page.
  46.         \end{document}}% \LaTeX\ redefines |\end|.
  47. \else
  48.     \let\FWEBend\end
  49. \catcode`\@@=12
  50. @ We can comment stuff out by bracketing it with |\comment...\endcomment|.
  51. \long\def\comment#1\endcomment{}
  52. @ Here's how to refer to the individual processors.  The user may wish to
  53. redefine these.
  54. \def\WEB{\Wtypewriter{WEB}}
  55. \def\FWEB{\Wtypewriter{FWEB}}
  56. \def\CWEB{\Wtypewriter{CWEB}}
  57. \def\TANGLE{\Wtypewriter{TANGLE}} \let\Tangle\TANGLE
  58. \def\WEAVE{\Wtypewriter{WEAVE}}   \let\Weave\WEAVE
  59. \def\FTANGLE{\Wtypewriter{FTANGLE}}
  60. \def\FWEAVE{\Wtypewriter{FWEAVE}}
  61. @ Here's how one can refer to the individual languages.  The user may also wish
  62. to redefine these.
  63. \def\C{C}
  64. \def\Cpp{\C{\tt ++}}
  65. \def\FORTRAN{{\Csc Fortran}} \let\Fortran\FORTRAN
  66. \def\MAKE{{\tt MAKE}}       \let\Make\MAKE
  67. \def\RATFOR{{\Csc Ratfor}}   \let\Ratfor\RATFOR
  68. \let\TEX\TeX
  69. \def\UNIX{{\SC UNIX}}    \let\Unix\UNIX
  70. @ Here's something for trickery with catcodes.
  71. \chardef\other=12
  72. @ Now remember Plain \TeX\ stuff used for other purposes by \FWEB.
  73. \let\amp\&
  74. \let\at\@@
  75. \let\bslash\\
  76. \let\caret\^
  77. \let\dollar\$
  78. \let\dstar\*
  79. \let\equals\=
  80. \let\leftbrace\{
  81. \let\period\.
  82. \let\rightbrace\}
  83. \let\vertbar|
  84. \let\PM\#
  85. \let\PC\%
  86. @ Additionally, the TeXbook manual macro package \.{manmac} redefines the
  87. following stuff: 
  88.  |\iftitle \titlefont \rhead \pagewidth \pageheight \output|
  89. \noindent If you want to include \.{manmac.tex} to get various macro
  90. definitions, the best scheme is to use the `\.{-w}'~command-line option to
  91. prevent \FWEAVE\ from outputting |\input fwebmac.sty| as the first output line.
  92. Then include both files explicitly, in this order:
  93.     |\input manmac|
  94.     |\input fwebmac.sty|
  95. \noindent You can do this by defining the first limbo text command as
  96. follows:
  97.  |@@l "\\input manmac \\input fwebmac.sty"|
  98. @ Paragraph skip and indentation for \TeX\ text:
  99. \newdimen\pardimen
  100. \dimen0=\normalbaselineskip
  101. \parskip=\dimen0 plus 1pt
  102. % If you don't like spaces between paragraphs, change |\pardimen| to |0pt|.
  103. \pardimen=\parskip 
  104. \parskip 0pt% No stretch between paragraphs
  105. % Indentation for the \TeX\ part is handled in a separate variable
  106. % |\TeXindent| from the variable |\notch| used for definition and code parts.
  107. \newdimen\TeXindent
  108. \TeXindent 1em% For paragraphs in the \TeX\ part.
  109. @* FONTS. Several fonts have been declared in addition to the standard of
  110. \.{PLAIN} format:
  111. $$\vbox{\halign{\.{\\#}\quad\hfil&---\quad#\hfil\cr
  112. titlefont&\titlefont Title.\cr
  113. ttitlefont&\ttitlefont Title.\cr
  114. SC&\SC SMALL CAPS.\cr
  115. Csc&\Csc CAPS/Small caps.\cr
  116. tentex&\tentex \TeX\ extended character set, including~'\.{\ }'.\cr
  117. bfit&\bfit Bold-faced italic.\cr
  118. The font used for comments is called |\cmntfont|.  By default, this is
  119. |\let| to |\tenrm|.
  120. \ifx\selectfont\undefined
  121.     \let\mainfont\tenrm \let\cmntfont\tenrm
  122.     \font\eightrm=cmr8 \let\SC\eightrm 
  123.     \font\titlefont=cmssbx10 scaled \magstep2% Sans serif
  124.     \font\ttitlefont=cmtt10 scaled\magstep2% Typewriter type
  125.     \font\tentex=cmtex10 % \TeX\ \.{extended char.\ set} (used in strings)
  126.     \font\Csc=cmcsc10 % Caps/small caps.
  127.     \font\tenbfit=cmbxti10 % \&{Intrinsic functions}
  128. % Used for module-number subscript:
  129.     \font\seventi=cmti7
  130.     \font\sevenrm=cmr7
  131.     \font\sevenbf=cmbx7
  132. % For special handling of array indices:
  133.     \font\sevenit=cmti7
  134.     \scriptfont\itfam=\sevenit
  135. @%\font\fiveit=cmti5
  136. @%\scriptscriptfont\itfam=\fiveit
  137.     \scriptscriptfont\itfam=\sevenit
  138. \else % NFSS
  139.     \def\mainfont{\fontfamily{\rmdefault}\fontseries{m}\fontshape{n}%
  140.         \normalsize}
  141.     \let\cmntfont\mainfont
  142.     \def\eightrm{\fontfamily{\rmdefault}\fontseries{m}\fontshape{n}%
  143.         \footnotesize}
  144.     \let\SC\eightrm
  145.     \def\titlefont{\fontfamily{\sfdefault}\fontseries{\bfdefault}%
  146.         \fontshape{n}\Large}
  147.     \def\ttitlefont{\fontfamily{\ttdefault}\fontseries{m}\fontshape{n}%
  148.         \Large}
  149.     \def\tentex{\fontfamily{\ttdefault}\fontseries{m}\fontshape{n}%
  150.         \normalsize}
  151.     \def\Csc{\fontfamily{\rmdefault}\fontseries{m}\fontshape{\scdefault}%
  152.         \normalsize}
  153.     \def\tenbfit{\fontfamily{\rmdefault}\fontseries{\bfdefault}%
  154.         \fontshape{\itdefault}\normalsize}
  155.     \def\seventi{\fontfamily{\rmdefault}\fontseries{m}%
  156.         \fontshape{\itdefault}\scriptsize}
  157.     \def\sevenrm{\fontfamily{\rmdefault}\fontseries{m}\fontshape{n}%
  158.         \scriptsize}
  159.     \def\sevenbf{\fontfamily{\rmdefault}\fontseries{\bfdefault}%
  160.         \fontshape{n}\scriptsize}
  161.     \def\fiveti{\fontfamily{\rmdefault}\fontseries{m}%
  162.         \fontshape{\itdefault}\tiny}
  163.     \def\fiverm{\fontfamily{\rmdefault}\fontseries{m}\fontshape{n}\tiny}
  164.     \def\fivebf{\fontfamily{\rmdefault}\fontseries{\bfdefault}%
  165.         \fontshape{n}\tiny}
  166.     \def\tensy{\fontfamily{cmsy}\fontseries{m}\fontshape{n}\normalsize}
  167.     \def\pbf{\fontfamily{\rmdefault}\fontseries{\bfdefault}\fontshape{n}%
  168.         \selectfont}
  169.     \def\ptt{\fontfamily{\ttdefault}\fontseries{m}\fontshape{n}\selectfont}
  170. % The next isn't really sufficient; this ought to be put into
  171. % the definitions of |\tenpoint|, |\twelvepoint|, etc.
  172.     \let\bfit\tenbfit 
  173. @* HIGHLIGHTING MACROS.  These are used for displaying identifiers,
  174. reserved words, intrinsic functions, etc.
  175. \def\Wshort#1{\leavevmode\hbox{$#1$}}% One-letter identifiers such
  176.     % as~\Wshort{x} look better this way.
  177. \def\Wid#1{\leavevmode\hbox{\it#1\/\kern.05em}}% Italic type for ordinary
  178.     % identifiers such as \Wid{test}.
  179. % By default, macros are formatted the same way as ordinary identifiers.
  180. % However, you can change the following definitions to get special effects.
  181. % Either make your own version of |fwebmac.sty| (use a change file with
  182. % |fwebmac.web|), or redefine |\WidD| and/or |\WidM| with an \.{@@l} command.
  183. \let\WidD\Wid % Outer macro
  184. \let\WidM\Wid % WEB macro
  185. \def\Wreserved#1{\leavevmode\hbox{\def\\{\tt\BS}\bf#1\/}}% Boldface type
  186.     % for reserved words such as \&{integer}.
  187. \def\Wintrinsic#1{\leavevmode\hbox{\def\\{\tt\BS}\bfit#1\/\kern.05em}}%
  188.     % Library/intrinsic function name such as \@@{sin}.
  189. % In the following, we use |\gdef| instead of |\global\let| because we
  190. % might want to change the definition of, e.g., |\WidM| with an \.{@@l}
  191. % command, which comes \It{after} the |\Wbegin| statement.
  192. \def\Wequate#1#2#3#4#5#6#7#8{%
  193.     \gdef#1{\Wreserved}% |\&| by default.
  194.     \gdef#2{\Wshort}% |\|| by default.
  195. % Don't reorder the following three statements! In case arguments 3--5 are
  196. % identical, we want the ordinary identifier to win.
  197.     \gdef#5{\WidM}% |\\| by default.
  198.     \gdef#4{\WidD}% |\\| by default.
  199.     \gdef#3{\Wid}% |\\| by default.
  200.     \gdef#6{\Wintrinsic}% |\@@| by default.
  201.     \gdef#7{\Wkeyword}% |\.| by default.
  202.     \gdef#8{\Wtypewriter}}% |\.| by default.
  203. @ Identifiers that are recognized as function or macro names are followed
  204. by the construction\hfil\break
  205. \.{\\WIN\{{\it name}\_{\it type}\}\{{\it module}\_{\it number}\}}.  The
  206. cases for the first argument correspond to 
  207. $$\vbox{\halign{#\hfil&\ ---\ #\hfil\cr
  208. 0&Generic name, defined by \.{@@[}.\cr
  209. 1&Function name.\cr
  210. 2&\WEB\ macro (\.{@@m}).\cr
  211. 3&Outer macro (\.{@@d}).\cr
  212. 4&Reserved name defined with~\.{@@`}.\cr
  213. 5&|@c typedef| name.\cr
  214. If the name was defined in the current module, the second argument will be
  215. zero; otherwise it will be the section number in which the name was
  216. defined.  The macro shows how to display the 0~state differently (here with
  217. a bullet).   Also, note how combinations of underlining and fonts are used
  218. to distinguish the various kinds of identifiers.
  219. \def\Wzero{0}
  220. \def\WIN#1#2{\ifmmode\def\ZZ{}\else\def\ZZ{\null$\null}\fi
  221.     \ZZ_{\def\next{#2}\ifx\next\Wzero{\bullet}\else\WINo{#1}{#2}\fi}\ZZ}
  222. % Format the module-number subscript.
  223. \def\WINo#1#2{%
  224.     \ifcase#1\underline{\hbox{\sevenrm#2}}% Generic name (\.{@@[}). [0]
  225.         \or\hbox{\sevenrm#2}% Function name. [1]
  226.         \or\underline{\hbox{\seventi#2}}% WEB macro. [2]
  227.         \or\hbox{\seventi#2}% Outer macro. [3]
  228.         \or\underline{\hbox{\sevenbf#2}}% \.{@@`}. [4]
  229.         \or\hbox{\sevenbf#2}% \&{typedef}. [5]
  230.         \else{#2}% Error trap.
  231.     \fi}
  232. @* STRINGS. Strings are indicated by ``\.{\\.\{\dots\}}''.  You can also
  233. use this for typewriter type; remember to escape the appropriate symbols:
  234. ``\.{\ \\\#\%\$\^\{\}\~\&\_}''.  The string macro itself does not surround
  235. its contents with an |\hbox|, in order that long strings can be broken by
  236. discretionaries.
  237. \def\Wtypewriter#1{\relax\ifmmode\gdef\YY{\null$\null}\else\gdef\YY{}\fi
  238.     \YY{\leavevmode\INITSTR#1}\YY}
  239. \let\Wkeyword\Wtypewriter
  240. @ Here is the nucleus for the string macro~|\.| (more precisely, for
  241. |\Wtypewriter|).
  242. \def\INITSTR{%
  243.     \tentex % Typewriter type for strings
  244.     \let\\=\BS % Backslash in a string: '\.\\'.
  245.     \let\'=\RQ % Right quote in a string: '\.\''.
  246.     \let\`=\LQ % Left quote in a string: '\.\`'.
  247.     \let\{=\LB % Left brace in a string: '\.\LB'.
  248.     \let\}=\RB % Right brace in a string: '\.\RB'.
  249.     \let\~=\TL % Tilde in a string: '\.\~'.
  250.     \let\ =\SP % Space in a string: '\.\ '.
  251.     \let\_=\UL % Underline in a string: '\.\_'.
  252.     \let\&=\AM % Ampersand in a string: '\.\&'.
  253.     \def\0{\discretionary{\BS}{}{}}% FWEB inserts this automatically every
  254.       % so often so very long strings will break. Broken strings will
  255.       % be marked by a backslash.
  256.     \def\1{,\0}% FWEB replaces commas in strings by this, so strings
  257.         % tend to break after commas.
  258.     \let\2\space % Ordinary space after control sequences in \TeX.
  259.     \def\3{\space\space}% Translation of a tab in \TeX.
  260. @ Characters for strings:
  261. \def\#{\hbox{\tt\char35}}% Parameter sign: '\#'.
  262. \def\${\hbox{\tt\char36}}% Dollar sign: '\$'.
  263. \def\%{\hbox{\tt\char37}}% Percent sign: '\%'.
  264. \def\^{\ifmmode\raise0.45ex\hbox{$\,\scriptstyle\mathchar"25E\,$}%
  265.     \else\char`^ \fi}% Pointer or 
  266.     % hat: '\^'. 
  267.     % Circumflex accents can be obtained from |\^^D| instead of |\^|.
  268. \def\AT!{@@}% At sign for control text: '\AT!'
  269. @ The following funny business about asterisks is in case you want to be
  270. clever and make~`\.*' an active character (for example, for complex
  271. conjugation). 
  272. \chardef\asterisk=`\*
  273. \def\ast{\ifmmode{\displaystyle\mathchar"2203}\else\asterisk\fi} 
  274. @ More stuff for strings.
  275. \chardef\AM=`\&% Ampersand character in a string: '\.\&'.
  276. \chardef\BS=`\\% Backslash in a string: '\.\\'.
  277. \def\ttBS{{\tt\BS}}% Literal backslash: '\ttBS'.
  278. \chardef\LB=`\{% Left brace in a string: '\.\LB'.
  279. \def\LQ{{\tt\char'22}}% Left quote in a string: '\.\`'.
  280. \chardef\RB=`\}% Right brace in a string: '\.\RB'.
  281. \def\RQ{{\tt\char'23}}% Right quote in a string: '\.\''.
  282. \def\SP{{\tt\char`\ }}% (Visible) space in a string: '\.\ '.
  283. \chardef\TL=`\~% Tilde in a string: '\.\~'.
  284. \chardef\UL=`\_% Underline character in a string: '\.\_'.
  285. \def\LA{\hbox{\LQ}}% Left quote outside a string
  286. @* INDENTATION, LINEBREAKS, etc.  These commands are mostly handled by the
  287. macros~|\1| to~|\8|.
  288. First, here are some macros to draw vertical lines to show off the indentation
  289. scheme.
  290. \newbox\rulebox
  291. \newcount\ruleno
  292. \def\rules#1{\leavevmode
  293.     \ruleno=0
  294.     \rlap{\vtop to 0pt{\null
  295.         \def\R{\setbox0=\hbox{\the\ruleno}%
  296.             \rlap{\vrule height0pt depth#1}%
  297.             \kern-0.5\wd0\copy0\kern-0.5\wd0
  298.             \advance\ruleno by1
  299.             \hskip1em}
  300.         \rlap{\R\R\R\R\R\R\R}
  301.         \vss}}}
  302. @ The indentation scheme is as follows.  The unit of indentation is
  303. |\notch|.
  304. \newdimen\notch
  305. \notch 1em
  306. @ Here is typical output.
  307. \setbox\rulebox\vtop{\null
  308. \WY $\WP\WE:if:\WO{1}{}$\par
  309. \WP\WMd$\@|A\WIN2{0}$\5
  310. $\WO{2}{}$\par
  311. \WP\WE:endif:\par
  312. \WP\WMD$\\{ALPHA}$\5
  313. $\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+%
  314. \\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+%
  315. \\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+%
  316. \\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+%
  317. \\{xxx}+\\{yyy}+\\{xxx}{}$\par
  318. \WY\WP$\\{main}(\,)$\1\1\6
  319. \&{int} \1\\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, %
  320. \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, %
  321. \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde};\2%
  322. \2\2\1\6
  323. $\{{}$\6
  324. \WE:if:$\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+%
  325. \WO{2222}+\WO{1111}+\WO{2222}+\\{aaaa}+\\{bbbb}+\WO{1111}+\WO{2222}+\WO{1111}+%
  326. \WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}$\WPs\7
  327. $\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+%
  328. \\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+%
  329. \\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\z;{}$%
  330. \WE:endif:\WPs\6
  331. $\}$\2\WY\par
  332. \vbox{\noindent\rules{\dp\rulebox}\box\rulebox}
  333. Preprocessor commands in the definition part are far left, definition-part
  334. commands such  
  335. as~\.{@@m} are indented one notch, function names are at two notches, and
  336. the body of functions is at three notches.  This distance is given the
  337. special name |\globalindent|:
  338. \newcount\globalindent
  339. \globalindent=3 % Global indentation in notches.
  340. @ The current indentation is called |\ind|.  We also sometimes need to save
  341. and restore that.
  342. \newcount\ind % Current indentation in notches.
  343. \newcount\lastind % Used for preprocessor commands.
  344. \def\saveind{\global\lastind=\ind}
  345. @ Each output line of code is a separate paragraph.  The scheme proceeds by
  346. first setting |\ind|~to the appropriate hanging indentation, then
  347. backspacing appropriately.  Here are the backspace quantities.
  348. \newbox\bak  \setbox\bak=\hbox to -\notch{}% Backspace one notch.
  349. \newbox\bakk \setbox\bakk=\hbox to -2\notch{}% Backspace two notches.
  350. @ When there's the possibility that a line of code may be continued, we
  351. advance the indentation and set |\hangindent|.
  352. \def\1{\global\advance\ind by1\hangindent\ind\notch}% Indent one more notch
  353. @ Here we cancel the above.  We don't need to reset |\hangindent| because
  354. this will always be followed by a~|\6| or~|\7|, which already does that.
  355. \def\2{\global\advance\ind by-1{}}% Indent one less notch
  356. @ Now we provide for an optional break within a statement.  (Note that the
  357. argument is multiplied by~10.)
  358. \def\3#1{\hfil\penalty#10\hfilneg}% Optional break within a statement.
  359. @ A simple command to backspace one notch.
  360. \def\4{\copy\bak}% Backspace one notch
  361. @ Optional break (the |\yskipfalse| may be obsolete).
  362. \def\5{\hfil\penalty-1\hfilneg \kern2.5\notch\copy\bakk
  363.     \yskipfalse\ignorespaces}
  364. @ The next command forces a line break.
  365. \def\6{\ifmmode\else\par
  366.     \hangindent\ind\notch \noindent \kern\ind\notch \copy\bakk \ignorespaces\fi}
  367. @ This also forces a line break, but also adds some extra vertical space.
  368. \def\7{\WY\6}% Forced break and a little extra space.
  369. @ No indentation.
  370. \def\8{\hskip-\ind\notch \hskip 2\notch}
  371. \newif\ifyskip
  372. \def\yskip{\medskip}
  373. @* PREPROCESSOR COMMANDS.  The preprocessor commands are built out of the
  374. previous ones.
  375. First, we define a guaranteed space.
  376. \def\Hspace{\hbox{ }}
  377. @ Start a preprocessor command such as \.{@@\#if}.  When these are issued
  378. in the 
  379. code section (rather than in the definition section), we must remember the
  380. present level of indentation.  That's restored with~|\WPs|.
  381. \def\WPR#1{\copy\bakk \saveind%    |\global\advance\ind by 2|
  382.     \1\Wreserved{@@#1}\Hspace}
  383. \def\WPs{\global\ind=\lastind}
  384. @ The definition commands such as~\.{@@m} are similar, except that they
  385. also take a language argument.
  386. \def\defin#1#2{\4\saveind
  387.     \1\Wreserved{#1}\hbox{$^{\rm#2}$}\Hspace}% Begin @@d, @@m, or @@f.
  388. @* Various NUCLEII.
  389. \def\note#1#2.{\WY\noindent{\hangindent2em\baselineskip10pt\eightrm#1 #2.\par}}
  390. \def\lapstar{\rlap{*}}
  391. % If there's a current include file, it's printed at the start of each section.
  392. \def\includefile{}
  393. \def\WIF#1{\def\includefile{#1}}
  394. \def\startsection{\WQ\noindent{\let\*=\lapstar\bf\modstar.%
  395. \ifx\includefile\empty\else\ [{\tt\includefile}]\fi\quad}}
  396. @* ALPHABET macros.  These are hard-coded into \FWEAVE.
  397. @*1 Comments. Comments are C-style.  The long comment construction `|/* ...
  398. */|' is output as `|\WC{ ... }|'; the short comment is output as `|\Wc{ ...
  399. }|'. The |\WC| and~|\Wc| macros aren't simply defined with an argument
  400. whose text would be the comment because one wants the comment to be a group
  401. and the user might be wanting to change catcodes inside that group; the
  402. argument form would absorb catcodes before they were changed.
  403. \def\skipbrace#1{\catcode`\{=1 }
  404. \def\WC{\Wcmnt{\ast}{\finishcomment}}
  405. \def\Wc{\Wcmnt{/}{\XX}}
  406. \def\Wcmnt#1#2{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi% C-style cmnt
  407.     \XX\hfil\penalty-1\hfilneg
  408.     \ifyskip\else\quad\fi$/#1\,$%
  409.     \bgroup\cmntfont % The user can redefine the comment font |\cmntfont|.
  410.         \aftergroup#2%
  411.         \catcode`\{=\other\skipbrace}
  412. \def\finishcomment{$\,\ast/$\XX}
  413. \def\Wx#1{\kern-0.5\notch\hbox{\tt\%}}
  414. @ Compiler directives are essentially comments, but are formatted more like
  415. preprocessor commands.
  416. \def\WCDIR#1{\WPR!\Wtypewriter{#1}\WPs}
  417. @*1 Code mode.  Code mode is entered by vertical bars, giving an effect
  418. such as |@c x=y|.
  419. \def\WCD#1{\ifmmode\hbox\fi{\ignorespaces#1}}
  420. @*1 Definitions. Various definition section stuff.
  421. \def\WD:#1:{\defin{@@D}{#1}}% Outer macro definition: `\.{@@D}' 
  422. \def\Wd:#1:{\defin{@@d}{#1}}% Outer macro definition: `\.{@@d}' 
  423. \def\WUd:#1:{\defin{@@u}{#1}}% Undef outer macro: `\.{@@u}'.
  424. \def\WMD{\defin{@@M}{}}% WEB macro definition: `\.{@@M}'.
  425. \def\WMd{\defin{@@m}{}}% WEB macro definition: `\.{@@m}'.
  426. \def\WE:#1:{\WPR{\##1}}% WEB preprocessor command: `\.{@@\#if\dots}'.
  427. \def\WF:#1:{\defin{@@f}{#1}}% Format definition: `\.{@@f}'.
  428. \def\Wl:#1:{\defin{@@l}{#1}}% Limbo text definition: `\.{@@l}'.
  429. \def\Wv:#1:{\defin{@@v}{#1}}% Operator overloading: `\.{@@v}'.
  430. \def\WWW:#1:{\defin{@@W}{#1}}% Identifier overloading:  `\.{@@W}'.
  431. \def\Ww:#1:{\defin{@@w}{#1}}% Identifier overloading:  `\.{@@w}'.
  432. @*1 Sections. Beginning of ordinary section (begun with~`\.{@@\ }').
  433. \outer\def\WM#1.{\MN#1.\Wmark\ifon\Wskip\startsection\ignorespaces}
  434. @ Beginning of starred section (begun with~`\.{@@*}').  Starred sections
  435. have associated level numbers, where 0~denotes the most significant level,
  436. 1~denotes a subsection, 2~denotes a subsubsection, and so on.  You can
  437. indicate the level number in several ways.  By default, you can say
  438. ``\.{@@*3\ Section name.}'' or equivalently ``\.{@@*...\ Section name.}''
  439. to set the level number to~3.  Alternatively, if you replace the line below
  440. ``\.{\\dotsafterfalse}'' with ``\.{\\dotsaftertrue}'', you can instead say
  441. ``\.{@@*\ Section name....}'' By default, major sections get a page break;
  442. subsections don't.  Sections and subsections can be formatted in different
  443. ways in the table of contents by enhancing the definition of~|\WZ|
  444. (inside~|\Wcon|) to include an |\ifcase| construction.  (See how this is
  445. done in |fwebman.tex|.)
  446. \newcount\Wss % Counter for the dots.
  447. \newif\ifdotsafter % Do subsection dots come after or before the section name?
  448. \dotsafterfalse
  449. \ifdotsafter % ``@@* NAME...''
  450.     \def\Wbefore:#1.{\Wdefname#1.\Wdot}%
  451.     \def\Wafter{\WNss}%
  452. \else % ``@@*.. NAME.'' or ``@@*2 NAME.''
  453.     \def\Wbefore: #1{\def\next{\Wafter#1}% Case for neither dot nor number.
  454.         \ifx#1.\def\next{\Wdot.}% Count arbitrary dots.
  455.         \else\ifx#11\Wsectionnum1%
  456.         \else\ifx#12\Wsectionnum2%
  457.         \else\ifx#13\Wsectionnum3%
  458.         \else\ifx#14\Wsectionnum4% Highest numerical level allowed.
  459.         \fi\fi\fi\fi\fi
  460.         \next}%
  461.     \def\Wafter#1.{\Wdefname#1.\WNss}% Executed after figuring out level.
  462. \def\Wsectionnum#1{\Wss#1\let\next\Wafter}% Assign numerical section number.
  463. \def\Wdefname#1.{\def\Wname{#1}}% Remember name of section.
  464. \outer\def\WN#1.{\MN#1.\Wss=0\Wbefore:}% Begin a starred section.
  465. @ Here we count the periods before or after the section name.
  466. \def\Wdot{\futurelet\next\WNs}
  467. \def\WNs{\ifx\next.\advance\Wss by 1\let\next\Wnext\else\let\next\Wafter\fi
  468.     \next}
  469. \def\Wnext#1{\Wdot}
  470. @ Now actually begin the section.  Note the use of~|\ifcase| to
  471. conditionally format the sections and subsections.  Also, the construction
  472. |\ifon...\fi| brackets the section to conditionally suppress printing.
  473. Finally, we make an entry in the table of contents for all starred names.
  474. The first argument of the \.{\\WZ}~macro is the level number for this
  475. section.  This can be used to format the table of contents in various ways.
  476. The order of expansion is an issue in the~|\write| to the table of contents
  477. file~|\cont|.  We want the macro~|\WZ| to be sent unexpanded, so we
  478. |\let|~it equal to a primitive.  Also, it's possible that a~|\WIN| will
  479. appear inside of~|\Wname| (if the user included certain kind of code inside
  480. the section name).  This shouldn't be expanded until later, so we turn that
  481. into the temporarily unexpandable macro~|\WIM|.
  482. % Page break for major sections.
  483. \def\Wsectionbreak{\ifcase\Wss\vfil\eject\fi}
  484. % Running headline.
  485. \def\rhead{\ifcase\Wss
  486.         \uppercase{\ignorespaces\Wname}%
  487.     \else
  488.         \ignorespaces\Wname%
  489.     \fi}% Define running headline.
  490. \let\WZ\let % Now you can |\send| the control sequence |\WZ|
  491. \let\WIM\let % This macro is made temporarily unexpandable; see |\WZ|.
  492. \def\WNss{%
  493.     \Wmark % Can't put this in |\MN| since |\rhead| must be defined first. 
  494.     \Wsectionbreak % Typeset the break between sections.
  495.     \message{*\modno}% Progress report to the terminal.
  496.     \ifon
  497.         \ifcase\Wss\else\Wskip\fi
  498.         \startsection{\bf\ignorespaces\Wname.\quad}%
  499.         {\def\WIN{\WIM}%
  500.         \edef\next{\write\cont{\WZ{\the\Wss}{\Wname}%
  501.         {\modno}{\noexpand\the\pageno}}}\next}%
  502.             % To contents file |CONTENTS.tex|.
  503.         \ignorespaces}
  504. @ The marks that we emit just before |\Wsectionbreak| are of the form
  505. ``{\it modno}|\else|{\it section name}''.  We use both of the parts in the
  506. page headers.  In handling the section name, we must take care to avoid
  507. expanding the macro~|\WIN| prematurely.  This is done just as in~|\WNss| above.
  508. \def\WmarkN{\def\Wmark{{\def\WIN{\WIM}
  509.         \mark{\modno\noexpand\else\rhead}}}}
  510. \ifx\selectfont\undefined
  511.     \WmarkN
  512. \else
  513.     \def\Wmark{{\def\WIN{\WIM}\let\protect\noexpand
  514.         \mark{\modno\noexpand\else\rhead}}}
  515. \def\Wmodno{\iftrue\topmark\fi}% Extracts the left-hand part of the mark.
  516. \def\Whead{{\let\WIM\WIN
  517.     \expandafter\iffalse\topmark\fi}}% Extracts the right-hand part.
  518. @ Common code for |\WM|, |\WN|.  
  519. \catcode`\@@=11
  520. \def\MN#1.{\par
  521.     \parskip=\pardimen % Reset to \TeX\ spacing
  522.     \parindent=\TeXindent
  523.     {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}
  524.     \ifLaTeXisloaded
  525.         \xdef\@@currentlabel{\modno}%
  526.     \ifx\modno\modstar \onmaybe \else\ontrue \fi}
  527. \catcode`\@@=12  
  528. @*1 Constants.  Various kinds of constants are handled:  decimal~(|@c 10|),
  529. hexadecimal~(|@c 0xA|), octal~(|@c 012|), boolean~(|@c 0b1010|), 
  530. floating-point (|@c 1.5e-35|), double-precision (|@n @e3.2d100|),
  531. long (|@c 99999L|), unsigned (|@c 99999U|),
  532. unsigned long (|@c 999999UL|), and Hollerith (|@r 3Habc|).
  533. \def\WDP#1{\ifx E#1\else{\tt#1}\fi}% Used in the exponent macro below.
  534. \def\WO#1{%
  535.     {% Make the next definitions local.
  536.     \let\-\_%
  537.     \let\d\$%
  538.     \def\\{\let\_\-\let\$\d}%
  539.     \def\?{\kern.2em}%
  540.     \def\###1{\kern0.1em{\tt \ifcase##1F\or L\or U\or UL\else?\fi}}%C~constant. 
  541.     \def\^##1{\cdot 10^{\aftergroup}\aftergroup\WDP\aftergroup##1}% Power of ten
  542.     \def\_{_{\\\rm\aftergroup}}% Fortran-90 kind parameter.
  543.     \def\%{{\rm H}\hbox{\aftergroup}\Wtypewriter{\aftergroup}}% Hollerith constant
  544.     \def\&{0{\tt b}}% Binary constant.
  545.     \def\~{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}}% Octal
  546.     \def\`{\hbox{\rm\char"7D\tt\aftergroup}}#1}}% Double quotes for hex constant
  547. @*1 Code mode.  Either begin the code section, or a preprocessor or
  548. definition command.
  549. The following command sets up~|\ind|.  This somewhat peculiar construction
  550. is for historical reasons.
  551. \def\WPr{\global\ind=\globalindent \1}
  552. @ Now enter code mode.  Note that |\leavevmode| starts a new indented
  553. paragraph; we then move in one more notch.
  554. \def\WP{\parskip=0pt \parindent=\notch
  555.     \rightskip=0pt plus 100pt minus 10pt 
  556.     \sfcode`;=3000
  557.     \pretolerance 10000
  558. @#if 0
  559.     \hyphenpenalty 10000 \exhyphenpenalty 10000 % If you turn these on, the
  560.     % discretionary breaks in strings won't work!
  561.     \global\ind=\globalindent \1\ \unskip}
  562. @#endif
  563.     \WPr
  564.     \leavevmode\kern\notch}
  565. @ Here we leave code mode:
  566. \def\WQ{\rightskip=0pt
  567.     \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 }
  568. @*1 Miscellaneous operators.
  569. \def\WA{\note{See also}}% Cross-reference for multiply defined section names.
  570. \def\Wauto[#1]{\Wtypewriter{[#1]}\ }
  571. \def\WB{\mathopen{\Wtypewriter{@@/\ast}}}% Begin controlled comment.
  572. \let\WG\ge % Greater than or equal sign: '$\WG$'.
  573. \let\WI\neq % Unequal sign: '$\WI$'.  (Better reserve |\ne| for the
  574.         % electron density~$n_e$.) 
  575. \def\WJ{\Wtypewriter{@@\&}}% TANGLE's join operation: '\WJ'.
  576. \let\WK\gets % Left arrow: '$\WK$'.
  577. \let\WL\le % Less than or equal sign: '$\WL$'.
  578. \def\Wskip{\vfil\penalty-100\vfilneg \vskip12ptminus3pt}% See |\WM|, etc.
  579. \def\Wskipped#1{\8\mathhexbox278.\quad\Wtypewriter{@@I "#1"}\ \ {\it Section(s)
  580. skipped}\dots\WP} 
  581. \let\WPtr\Rightarrow % Fortran's stupid pointer assignment statement:
  582.         % '$\WPtr$'. 
  583. \let\WR=\lnot % Logical not: '$\WR$'.
  584. \let\WS=\equiv % Equivalence sign: '$\WS$'.
  585. \def\WT{\mathclose{\Wtypewriter{@@\ast/}}}% Terminate controlled comment.
  586. \def\WU{\note{This code is used in}}% Cross-reference for uses of sections.
  587. \let\WV\lor % Logical or: '$\WV$'.
  588. \let\WW=\land % Logical and: '$\WW$'.
  589. @ Here's how to format a section name. Argument~1 is the name, argument~2
  590. is the section number, and argument~3 is the language symbol.
  591. \def\WX#1:#2\X#3\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi
  592.     \XX$\langle\,$#2{\eightrm\kern.5em#1}$\,\rangle^{\rm #3}$\XX}
  593. \def\WY{\par\parskip=0pt\yskip} 
  594. @* VARIOUS OPERATORS.
  595. The following were for Pascal.
  596. @<Unused@>=
  597. \def\){\hbox{\Wtypewriter{@@\$}}}% sign for string pool check sum
  598. \def\]{\hbox{\Wtypewriter{@@\\}}}% sign for forced line break
  599. @  For C's construciton `|@c x ? 1 : 0|'.
  600. \def\?{\mathrel?}
  601. @ Colons have several uses.
  602. \def\Colon{\ifmmode\colon\else:\fi}
  603. \def\CC{\mathord{::}}% '$x\CC y$'.
  604. \def\CF{{}\mathbin{::}{}}% '$x\CF y$'.
  605. @ Verbatim strings are boxed for emphasis, like this:  \Wequals{This is a
  606. verbatim string.}
  607. \def\=#1{\kern2pt\hbox{\vrule\vtop{\vbox{\hrule
  608.     \hbox{\strut\kern2pt\Wtypewriter{#1}\kern2pt}}
  609.     \hrule}\vrule}\kern2pt}
  610. \let\Wequals\=
  611. \let\~=\ignorespaces
  612. \let\*=*
  613. @ The following symbol is used to denote accretions to already-existing
  614. modules. 
  615. \def\PQ{\mathrel{+\mathord\equiv}}% '$\PQ$'.
  616. \mathchardef\TLD="0218% '$\TLD$'.
  617. \def\PP{\mathord{++}}% '$\PP$'.
  618. \def\MM{\mathord{--}}% '$\MM$'.
  619. \def\MG{\mathord{\to}}% '$\MG$'.
  620. @ The exponentiation macros strip away outer parentheses from the argument,
  621. turning ``|x^(a+b)|'' into ``|@n x^(a+b)|''.
  622. \def\LP{(}% Must be |\def|, not |\let|.
  623. \def\ISL#1#2]{\def\next{#1}}
  624. \def\EE#1{\ISL#1]\ifx\next\LP\EXP[#1]\else\EXP[(#1)]\fi}
  625. \def\EXP[(#1)]{^{#1}}
  626. @#if 0
  627. \def\EE{\mathord{\hbox{\tt\^}}}% Poor-man's exponentiation; above is better.
  628. @#endif
  629. \let\SlSl\parallel% Concatenation: '$\SlSl$'.
  630. @ For \Fortran--90's `|@n (/a,b,c/)|'.
  631. \def\LS{\mathopen{({/}}}
  632. \def\SR{\mathclose{{/})}}
  633. @ Macro stuff:
  634. \def\NN{\hbox{\#\#}}% '\NN'.
  635. \def\NP{\hbox{\#!}}% '\NP'.
  636. \def\NC{\hbox{\#:}}% '\NC'.
  637. \def\ND{\hbox{\#.}}% '\ND'.
  638. \def\Nq{\hbox{\#\tt'}}% '\Nq'.
  639. \def\NQ{\hbox{\#\tt"}}% '\NQ'.
  640. @ The standard \Fortran\ \.{.FALSE.} and \.{.TRUE.} operators.
  641. \def\FALSE{{\cal F}}% '$\FALSE$'.
  642. \def\TRUE{{\cal T}}% '$\TRUE$'.
  643. @ Compound operators.  The following are for~C.
  644. \def\Wcp{\mathrel{+{=}}} \let\PE\Wcp % `$x\PE y$'.
  645. \def\Wcm{\mathrel{-{=}}} \let\ME\Wcm % `$x\ME y$'.
  646. \def\Wcs{\mathrel{\ast{=}}} \let\TE\Wcs % `$x\Wcs y$'.
  647. \def\Wcv{\mathrel{/{=}}} \let\FE\Wcv % `$x\FE y$'.
  648. \def\Wcd{\mathrel{\%{=}}} \let\CE\Wcd % `$x\Wcd y$'.
  649. \def\Wcx{\mathrel{\^\!{=}}}% `$x\Wcx y$'.
  650. \def\Wca{\mathrel{\amp{=}}}% `$x\Wca y$'.
  651. \def\Wco{\mathrel{\OR{=}}}% `$x\Wco y$'.
  652. \def\Wcg{\mathrel{\GG\!{=}}}% `$x\Wcg y$'.
  653. \def\Wcl{\mathrel{\LL\!{=}}}% `$x\Wcl y$'.
  654. \def\EQV{\mathrel{?{=}}}% `$x\EQV y$'.
  655. \def\NEQV{\not\equiv}% `$x\NEQV y$'.
  656. @ More C operators.
  657. \def\MOD{\mathrel{\%}}% `$x\MOD y$'.
  658. \def\OR{{\,|\,}}% `$x\OR y$'.
  659. \def\AND{{\,\amp\,}}% `$x\AND y$.
  660. \def\GG{\mathrel{>\!>}}% `$x\GG y$'.
  661. \def\LL{\mathrel{<\!<}}% `$x\LL y$'.
  662. \def\HE{\mathrel{\uparrow=}}% `$x\HE y$'.
  663. @ We allow braces to be easily displayed outside of math mode.
  664. \let\openbraces=\{
  665. \let\closebraces=\}
  666. \def\{{\ifmmode\openbraces\else$\openbraces$\fi}
  667. \def\}{\ifmmode\closebraces\else$\closebraces$\fi}
  668. @ Metacomments:
  669. \def\WBM{\6\8\Wreserved{@@(}}
  670. \def\WEM{\6\8\Wreserved{@@)}}
  671. @ Block/loop numbers in \Fortran.  \It{Note:  You can't replace the
  672. |\bgroup| and |\egroup| by braces because of peculiarities of~|\Wc|.  Also,
  673. if you put an explicit comment on a line that will be labelled by
  674. |\Wblock|, with the following definition you'll get two comments side by
  675. side.  However, this could be modified by setting a counter to the block
  676. number and making a fancier definition of~|\WC| and~|\Wc|.}
  677. \def\Wblock#1{\Wc\bgroup\ Block #1\egroup}% `\Wblock{99}'
  678. @* OVERLOADING OPERATORS.  Operator overloading is annoying because several
  679. languages may be in use simultaneously.  Therefore, when we define an
  680. overloaded  macro name, we append to it the language symbol, creating
  681. macros such as |\op_C|.  These macros are typically defined automatically
  682. at the beginning of the output file from information contained in
  683. \.{@@v}~commands. 
  684. \newif\ifop
  685. \newbox\dotbox
  686. \def\Wunknown#1{\={??#1??}}% For unknown dot constant.
  687. {\catcode`\_=11
  688. \gdef\newop#1#2#3{%
  689.     \edef\next{\def\expandafter\noexpand\csname _#1_#2\endcsname}%
  690.     \next{#3}}
  691. \gdef\newbinop#1#2#3{%
  692.     \edef\next{\def\expandafter\noexpand\csname _#1_#2\endcsname}%
  693.     \next{\mathrel{#3}}}
  694. \gdef\newunop#1#2#3{%
  695.     \edef\next{\def\expandafter\noexpand\csname _#1_#2\endcsname}%
  696.     \next{\mathbin{#3}}}
  697. \gdef\Wop#1#2{\setbox\dotbox\hbox{\tt .#1.}%
  698.     \edef\nxt{\expandafter\noexpand\csname _#1_#2\endcsname}%
  699.     \edef\ifnxt{\noexpand\ifx\expandafter\noexpand\csname _#1_#2\endcsname}%
  700.     \ifnxt\empty
  701.         \def\next{\box\dotbox}% Macro not defined; just use \.{.NAME.}.
  702.     \else
  703.         \def\next{\futurelet\nextchar\Woq}% Be careful about |\EE|.
  704.     \next}%
  705. \global\let\Wb\Wop
  706. \global\let\Wu\Wop
  707. \let\Lbrace{
  708. \def\Woq{\ifx\nextchar\Lbrace
  709.         \let\next\nxt % There's an argument coming up.
  710.     \else
  711.         \ifop
  712.             \def\next{\nxt{}\equiv\box\dotbox}%
  713.         \else
  714.             \let\next\nxt
  715.         \fi
  716.     \opfalse
  717.     \next}
  718. @ The following is for special handling of array indices.
  719. \newtoks\WARRAYarga
  720. \newtoks\WARRAYargb
  721. \def\WXA#1{\begingroup
  722. % We don't want the identifiers to be in hboxes, because we want to get
  723. % |\scriptstyle| for subscripts.  (We should always be in math mode here.)
  724.     \def\Wshort##1{##1}%
  725.     \def\Wid##1{{\it ##1\/\kern.05em}}%
  726.     \global\WARRAYarga{#1}%
  727.     \futurelet\Wnext\WARRAYm}
  728. \def\WARRAYm{\ifx\Wnext\WXA
  729.         \global\let\Wnext\WARRAYn% Multiple indices in C:  a[i][j][k]
  730.     \else
  731.         \global\let\Wnext\relax
  732.         \WARRAY{\the\WARRAYarga}% Typeset the accumulated indices.
  733.     \endgroup
  734.     \Wnext}
  735. \def\WARRAYn#1#2{\WARRAYargb{#2}%
  736.     \edef\Wnext{\noexpand\WXA{\the\WARRAYarga,\the\WARRAYargb}}%Concatenate
  737.     \Wnext}
  738. % Change the following definition to get indices printed in interesting ways.
  739. \def\WARRAY#1{[#1]}% Default definition.
  740. \def\WSUB#1{_{\scriptstyle#1}}% E.g., subscript indices.
  741. @ Handle the \.{@@o}~command.
  742. \def\Wouto#1#2{\Wreserved{@@#1}\Hspace\Wtypewriter{#2}}
  743. \def\Wout#1{\Wouto{o}{#1}}
  744. \def\WOut#1{\Wouto{O}{#1}}
  745. @* TITLES.  Now we deal with the overall page format.
  746. If you want to list only the modules that have changed,
  747. together with the index, put the command `|\let\maybe=\iffalse|' in
  748. the limbo section before the first module of your \.{WEB} file. It's
  749. customary to make this the first change in your change file.
  750. \newif\ifon 
  751. \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
  752. @ Some flags, and the number of the table of contents.
  753. \newif\iftitle \newif\ifpagesaved
  754. \newcount\contentspageno
  755. @ Top line on left-hand pages:
  756. \def\lheader{\mainfont\the\pageno\eightrm\qquad\Whead\hfill\Wtitle\qquad
  757.     \ifnum\pageno=\contentspageno\else
  758.         \tensy x\mainfont\Wmodno
  759.     \fi}
  760. @ Top line on right-hand pages:
  761. \def\rheader{\ifnum\pageno=\contentspageno\else
  762.         \tensy x\mainfont\Wmodno
  763.     \eightrm\qquad\Wtitle\hfill\Whead
  764.     \qquad\mainfont\the\pageno}
  765. @ Here are the page dimensions (in inches).
  766. \def\pagewidtho{6.5}% The width of each page
  767. \def\pageheighto{8.7}% The height of each page
  768. \def\fullpageheighto{9}% Page height including headlines
  769. \newdimen\pagewidth \pagewidth\pagewidtho in
  770. \newdimen\pageheight \pageheight\pageheighto in
  771. \newdimen\fullpageheight \fullpageheight\fullpageheighto in
  772. \newdimen\pageshift \pageshift=0in% Shift righthand pages wrt lefthand ones
  773. \def\magnify#1{\mag=#1
  774.     \pagewidth\pagewidtho truein
  775.     \pageheight\pageheighto truein
  776.     \fullpageheight\fullpageheighto truein
  777.     \setpage}
  778. \def\setpage{\hsize\pagewidth \vsize\pageheight}% Use after changing page size.
  779. @ The output routine is for plain \TeX.
  780. \def\page{\box255 }
  781. \newif\ifidenticalpageheads
  782. \def\normaloutput#1#2#3{
  783.     \ifodd\pageno\hoffset=\pageshift\fi
  784.     \shipout\vbox
  785.         \vbox to\fullpageheight
  786.             \iftitle\global\titlefalse
  787.             \else \hbox to\pagewidth
  788.                 {\vbox to10pt{}%
  789.                 \ifidenticalpageheads#2\else
  790.                 \ifodd\pageno
  791.                     #3% Pg nos alternate left \& right.
  792.                 \else#2\fi
  793.                 \fi
  794.                 }%    
  795.             \fi
  796.             \vfill#1% Parameter |#1| is the page itself.
  797.     \global\advance\pageno by1}
  798. \def\Wname{{\tt FWEB} OUTPUT}% This section name is reset by starred sections.
  799. % An OPTIONAL TITLE can be defined by the user in his limbo section. 
  800. \def\Wtitle{}
  801. @ Here we provide a storage place for |\output|. If you include a macro
  802. package, such as \.{manmac}, that overrides the definition of |\output|
  803. \It{after} \.{fwebmac.sty},  you can get back the \.{fwebmac.sty} definition by
  804. saying 
  805.         |\input manmac|
  806.         |\output\Woutput|
  807. \newtoks\Woutput
  808. \Woutput\output% Remember FWEB's definition.
  809. @ It's very useful to know exactly when you made the run.
  810. \newcount\minutes
  811. \newcount\hours
  812. \hours=\time
  813. \divide\hours by 60
  814. \multiply\hours by 60
  815. \minutes=\time
  816. \advance\minutes by -\hours
  817. \divide\hours by 60
  818. \def\Time{\the\hours:\ifnum\minutes<10 0\fi\the\minutes}
  819. \def\Date{\ifcase\month\or
  820.     January\or February\or March\or April\or May\or June\or
  821.     July\or August\or September\or October\or November\or December\fi
  822.     \space\number\day, \number\year}
  823. @* TABLE OF CONTENTS. An entry is made in the table of contents for each
  824. starred section.  One can customize things with |\topofcontents| and
  825. |botofcontents|. 
  826. \def\topofcontents{\centerline{\titlefont\Wtitle}
  827.   \vfill} % This is the default.
  828. @ End the table of contents page:
  829. @#if 0
  830. \def\botofcontents{\vfill}% This makes the bottom of the contents page empty.
  831. @#endif
  832. \def\botofcontents{\vfill
  833. @#if 0
  834.     \rightline{My Name}% You can personalize your output here, for example.
  835. @#endif
  836.     \rightline{\Date}
  837.     \rightline{\Time}}
  838. \contentspageno=0% Default page number for table of contents
  839. @ Here we actually open up the contents file, which is the argument to
  840. |\Wbegin|.  The |\Wbegin| macro is issued automatically just before the
  841. stuff for the first module.
  842. \newwrite\cont % For the table of contents.
  843. \def\Wbegin[#1]#2#3#4#5#6{\edef\contentsfile{#5}%
  844.     \def\readcontents{\input\contentsfile}%
  845.     \Wequate#6
  846.     \ifLaTeXisloaded
  847.         \documentstyle[#1]{#2}%
  848.         \textwidth\pagewidth
  849.         \textheight\pageheight
  850.         \TeXindent#3
  851.         \begin{document}
  852.         \pageno=2
  853.     \else
  854.         \TeXindent#3
  855.     \notch#4
  856.     \output
  857.         {\setbox0=\page% The first page is garbage
  858.         \immediate\openout\cont=\contentsfile
  859.         \global\output{\normaloutput\page\lheader\rheader}%
  860. % Here we print out a garbage page, so that the first |\topmark| won't be null.
  861.     \setpage
  862.     \vbox to \vsize{}
  863. \def\Wch{\note{The following sections were changed by the change file:}
  864.     \let\*=\relax}
  865. @* INDEX.  The index is written by default into \.{INDEX.tex}, but that
  866. name can be overridden with the style-file entry \.{index.tex}.
  867. Here we begin the index:
  868. \newbox\Sbox % Saved box preceding the index
  869. \newbox\Lbox % Lefthand column in the index
  870. % The following macro is the style file entry \.{index.preamble}.
  871. \def\Winx{\par\vskip6pt plus 1fil
  872.     \write\cont{}% Ensure that the contents file isn't empty
  873.     \closeout\cont % The contents information has been fully gathered
  874.     \output{\ifpagesaved\normaloutput{\box\Sbox}\lheader\rheader\fi
  875.         \global\setbox\Sbox=\page \global\pagesavedtrue}
  876.     \pagesavedfalse \eject % Eject the page-so-far and predecessors
  877.     \setbox\Sbox\vbox{\unvbox\Sbox}% Take it out of its box
  878.     \vsize=\pageheight \advance\vsize by -\ht\Sbox % The remaining height
  879.     \hsize=.5\pagewidth \advance\hsize by -10pt
  880.         % Column width for the index (20pt between cols)
  881.     \parfillskip 0pt plus .6\hsize % Try to avoid almost empty lines
  882.     \def\lr{L}% This tells whether the left or right column is next
  883.     \output{\if L\lr\global\setbox\Lbox=\page \gdef\lr{R}
  884.         \else\normaloutput{\vbox to\pageheight{\box\Sbox\vss
  885.         \hbox to\pagewidth{\box\Lbox\hfil\page}}}\lheader\rheader
  886.         \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
  887. %  \message{Index:}
  888.     \parskip 0pt plus .5pt
  889.     \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em}% Index entry
  890.     \def\[##1]{$\underline{##1}$}% Underlined index item
  891.     \def\(##1){$^{\rm ##1}$}% Language marker
  892.     \let\Windexspace\medskip % Spacing between letter groups in index.
  893.     \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
  894.     \hyphenpenalty 10000 \parindent0pt}
  895. @ End the index.  This macro is the style-file entry \.{index.postamble}.
  896. \def\Wfin{\par\vfill\eject 
  897.     \ifpagesaved\null\vfill\eject\fi % Output a null index column
  898.     \if L\lr\else\null\vfill\eject\fi % Finish the current page
  899.     \parfillskip 0pt plus 1fil
  900.     \def\rhead{NAMES OF THE SECTIONS}
  901.     \output{\normaloutput\page\lheader\rheader}
  902.     \setpage
  903.     \def\note##1##2.{\quad{\eightrm##1 ##2.}}
  904.     \def\WU{\note{Used in}}% Cross-reference for uses of sections
  905.     \def\:{\par\hangindent 2em}\let\*=*}
  906. @ Begin the module list.  Presently, this is just an unused hook for
  907. special purposes; it is the style file entry \.{modules.preamble}.
  908. \let\Wmods\relax
  909. @* MISCELLANEOUS.
  910. Miscellaneous run info:
  911. \def\Winfo#1#2#3#4{\bigskip
  912.     \:{{\bf COMMAND LINE:}\ \ \Wtypewriter{#1}.}\smallskip
  913.     \:{{\bf WEB FILE:}\ \ \Wtypewriter{#2}.}\smallskip
  914.     \:{{\bf CHANGE FILE:}\ \ \Wtypewriter{#3}.}\medskip
  915.     \:{{\bf GLOBAL LANGUAGE:}\ \ \Wtypewriter{\rm #4}.}\medskip}
  916. @ Finish the section names,  do the table of contents and terminate:
  917. \def\Wcon{\par\vfill\eject
  918.     \rightskip 0pt \hyphenpenalty 50 \tolerance 200
  919.     \setpage
  920.     \output{\normaloutput\page\lheader\rheader}
  921.     \titletrue % Prepare to output the table of contents
  922.     \pageno=\contentspageno \def\rhead{TABLE OF CONTENTS}
  923.     \topofcontents
  924.     \catcode`\@@=11
  925.     \hbox to\hsize{\hfil Section\hbox to3em{\hss Page}}
  926.     \def\WZ##1##2##3##4{\hbox to\hsize{\kern##1em\ignorespaces##2
  927.         \leaders\hbox to .5em{.\hfil}\hfil\ ##3\hbox to3em{\hss##4}}}
  928.     \let\WIM\WIN % Restore the proper definition.
  929.     \readcontents\relax % Read the contents info.
  930.     \botofcontents 
  931.     \FWEBend}
  932. @ Assign a symbolic name to a module.  This scheme has no forward
  933. referencing at present for plain \TeX, although this could easily be
  934. extended.  For \LaTeX, forward referencing works because the \.{aux}~file
  935. is used.
  936. % Label a section with an identifying name.
  937. \def\modlabel#1{%
  938.     \ifLaTeXisloaded
  939.         \label{MOD#1}%
  940.     \else
  941.         \edef\next{\gdef\expandafter\noexpand\csname MOD#1\endcsname{\modno}}%
  942.         \next
  943.     \fi}
  944. % Print the number of a labelled section.
  945. \def\Wmodule#1{\ifLaTeXisloaded
  946.         \ref{MOD#1}%
  947.     \else
  948.         \csname MOD#1\endcsname
  949.     \fi} 
  950. % Examples of references to sections.  
  951. \def\WEBsection#1{section~\Wmodule{#1}}% |\section| is used by \LaTeX.
  952. \def\WEBmodule#1{module~\Wmodule{#1}}
  953. \let\module\WEBmodule% For backward compatibility.
  954. @ Language commands are printed in the left margin, following Knuth's
  955. solution in Appendix~A of the \TeX book.  They are actually printed one
  956. line down, because the language command is gobbled up before the line break
  957. is emitted.
  958. \def\strutdepth{\dp\strutbox}
  959. \def\marginal#1{\strut\vadjust{\kern-\strutdepth\specialmargin{#1}}}
  960. \def\specialmargin#1{\vtop to\strutdepth{
  961.     \baselineskip\strutdepth
  962.     \vss\llap{#1 }\null}}
  963. \def\LANGUAGE#1{\marginal{\smash{\vtop{\hbox{%
  964.     \hbox{\tt@@L\lowercase{#1}:\enspace}}\null}}}\ignorespaces}
  965. % Use the next one if you don't want language changes to be printed.
  966. @#if 0
  967.     \def\LANGUAGE#1{\relax\ignorespaces}
  968. @#endif
  969. @ The |\begintt| and |\endtt| verbatim constructions, borrowed from \TeX.
  970. \newskip\ttglue
  971. \ttglue=0.5em plus 0.25em minus 0.15em
  972. \def\ttother{\catcode`\\=\other \catcode`\{=\other \catcode`\}=\other
  973.     \catcode`\$=\other \catcode`\&=\other \catcode`\#=\other
  974.     \catcode`\%=\other \catcode`\~=\other \catcode`\_=\other
  975.     \catcode`\^=\other}
  976. \def\ttverbatim{\begingroup \ttother \obeyspaces \obeylines \tt}
  977. {\obeyspaces\gdef {\ }}
  978. \def\begintt{$$\let\par=\endgraf
  979.     \ttverbatim
  980.     \parskip=0pt
  981. %    \catcode`\@@=0
  982.     \rightskip=-\parindent
  983.     \ttfinish}
  984. \def\Begintt{\bgroup
  985.     \let\par=\endgraf
  986.     \ttverbatim
  987.     \parskip=0pt
  988.     \rightskip=-\parindent
  989.     \ttFinish}
  990. {\catcode`\|=0
  991.     |catcode`|\=\other
  992.     |obeylines%
  993.     |gdef|ttfinish#1^^M#2\endtt{#1|vbox{#2}|endgroup$$}%
  994.     |gdef|ttFinish#1\Endtt{#1|endgroup|egroup}}
  995. \let\verticalbar|
  996. \def\activebar{\catcode`\|=\active}
  997. {\activebar
  998. \gdef\normalbar{\activebar
  999.     \let|\verticalbar}}
  1000. %\activebar
  1001. {\obeylines%
  1002. \gdef\ttbar{\activebar%
  1003.     {\obeylines\gdef|{\ttverbatim%
  1004.         \spaceskip=\ttglue%
  1005.         \let^^M=\ \let|=\endgroup}}}}
  1006. \let\WCX\Begintt
  1007. @* INDEX.
  1008.